package controller.command;

import model.displayer.ShapeDisplayer;

import java.util.HashSet;
import java.util.Set;

public class ShapeResolveCmd extends CommandJFxImpl
{
    ShapeDisplayer composite;
    private Set<ShapeDisplayer> children;
    ShapeResolveCmd(ShapeDisplayer composite)
    {
        super(composite);
        this.composite = shape;
        this.children = new HashSet<>();
        for(ShapeDisplayer child: composite)children.add(child);
    }

    @Override
    public void execute()
    {
        for(ShapeDisplayer child : children)
        {
            child.setFather(null);
            composite.removeChild(child);
        }
    }

    @Override
    public void cancel()
    {
        for(ShapeDisplayer child : children)
        {
            composite.addChild(child);
            child.setFather(composite);
        }
    }
}
